package org.pub.fast.jdbc.generator;

import java.util.Calendar;

public class SystemTsGenerator {
	private java.lang.String getTimeStampString(long l) {
        java.util.Date d = new java.util.Date();
        java.util.Calendar cl = java.util.Calendar.getInstance();
        cl.setTime(d);
        int ia[] = new int[5];
        int year = cl.get(Calendar.YEAR);
        ia[0] = cl.get(Calendar.MONTH) + 1;
        ia[1] = cl.get(Calendar.DAY_OF_MONTH);
        ia[2] = cl.get(Calendar.HOUR_OF_DAY);
        ia[3] = cl.get(Calendar.MINUTE);
        ia[4] = cl.get(Calendar.SECOND);
        byte ba[] = new byte[19];
        ba[4] = ba[7] = (byte) '-';
        ba[10] = (byte) ' ';
        ba[13] = ba[16] = (byte) ':';
        ba[0] = (byte) (year / 1000 + '0');
        ba[1] = (byte) ((year / 100) % 10 + '0');
        ba[2] = (byte) ((year / 10) % 10 + '0');
        ba[3] = (byte) (year % 10 + '0');
        for (int i = 0; i < 5; i++) {
            ba[i * 3 + 5] = (byte) (ia[i] / 10 + '0');
            ba[i * 3 + 6] = (byte) (ia[i] % 10 + '0');
        }
        return new String(ba);
    }

    public String generateTS() {
        return getTimeStampString(System.currentTimeMillis());
    }
}
